package com.tag.controller;

import com.tag.entity.ApiResult;
import com.tag.entity.model.Tag;
import com.tag.entity.param.TagParam;
import com.tag.service.TagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "标签相关接口")
@RequestMapping("/tag")
public class TagController {

    @Autowired
    private TagService tagService;

    @ApiOperation(value = "添加标签", notes = "添加标签")
    @RequestMapping(value = "/addTag")
    public ApiResult addTag(@RequestBody Tag param){
        ApiResult apiResult = tagService.addTag(param);
        return apiResult;
    }

    @ApiOperation(value = "删除标签(主键)", notes = "删除标签(主键)")
    @RequestMapping(value = "/addTag")
    public ApiResult deleteTagById(@RequestBody Tag param){
        ApiResult apiResult = tagService.deleteTagById(param);
        return apiResult;
    }

    @ApiOperation(value = "更新标签(主键)", notes = "更新标签(主键)")
    @RequestMapping(value = "/addTag")
    public ApiResult updateTag(@RequestBody Tag param){
        ApiResult apiResult = tagService.updateTagById(param);
        return apiResult;
    }

    @ApiOperation(value = "查询标签(分页,多条件)", notes = "查询标签(分页,多条件)")
    @RequestMapping(value = "/addTag")
    public ApiResult selectTagList(@RequestBody TagParam param){
        ApiResult apiResult = tagService.selectTagList(param);
        return apiResult;
    }
}
